/**
 * 2
 *  
 * @Author : roryrywang
 * @DateTime : 24-9-7 下午7:34
 */

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    vector<char> vec;
    for (char ch = 'A'; ch <= 'Z'; ++ch) {
        vec.push_back(ch);
    }
    for (char ch = '0'; ch <= '9'; ++ch) {
        vec.push_back(ch);
    }

    int res = 0;
    for (char ch: vec) {
        int l = 0;
        int r = 0;
        int tmp = 0;
        while (r < n) {
            if (s[r] != ch) {
                tmp++;
            }
            while (tmp > k) {
                if (s[l] != ch) {
                    tmp--;
                }
                l++;
            }
            res = max(res, r - l + 1);
            ++r;
        }
    }

    cout << res << endl;

    return 0;
}

//7 1
//AABABBA
//11 1
//AABBAABBAAA